package com.guo.pet_store.admin.dao;

import com.guo.pet_store.admin.pojo.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface UserRepository extends JpaRepository<User,Long> {
    User findUserByUsernameAndPassword(String username,String password);
    User findUserByUsername(String username);

    @Transactional
    @Modifying
    @Query(nativeQuery = true,value = "update user set money = ?1")
    void changeMoney(Double money,Long userId);
}
